<?php
  require_once("../includes/config.php"); 
//Edit Pop-up"
  if($_SERVER["REQUEST_METHOD"] == "POST")
  {
    $name = $_POST['name'];
    $phone = $_POST['mobile'];
    $city= $_POST['city'];
    $representative= $_POST['client_id'];
    $email =$_POST['email'];

					  //if not admin or ceo
					  if ($_SESSION['r']<=1)
					{

							$discount = $_POST['discount'];

					}
					else
					{
							$discount="";
					}

    $address = $_POST['address'];

    
    $result = query("INSERT INTO companies (company_name,company_phone, city, representative_id,company_email 
	                 ,discount_for_company,company_address,owner_id) VALUES (?,?,?,?,?,?,?,?)", 
    $name,$phone,$city,$representative,$email,$discount,$address,$_SESSION['user_id']);
    $_SESSION['success_message'] = "تم إضافة الشركة بنجاح"; 
    
    redirect("customers.php?check=1");
  }
  else
    apologize("Sorry!");
	?>